package multithread.ThreadPool;

import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolTest {
    public static void main(String[] args) {

        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(2, 5, 20, TimeUnit.SECONDS,
                new LinkedBlockingDeque<>());

        threadPool.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程控制的任务");
            }
        });

        threadPool.shutdown();//设置线程池的状态为Shutdown，然后中断所有没有正在执行的任务
        threadPool.shutdownNow();//设置线程池的状态为stop，然后尝试停止所有的正在执行或暂停任务的线程，并返回等待执行任务的列表


    }

}
